package com.coder.books.thinkinjava.exceptions;

import static com.coder.util.Print.println;

/**
 * 12.8.2
 *
 * @author yuhushuan
 * @date 2020/7/29 11:31
 */
public class MultipleReturns {
    public static String f(int i) {
        println("Initialization that requires cleanup");
        try {
            println("Point 1");
            if (i == 1)
                return "return 1";
            println("Point 2");
            if (i == 2)
                return "return 2";
            println("Point 3");
            if (i == 3)
                return "return 3";
            println("end");
        } finally {
            println("Performing cleanup");
        }
        return "return";
    }

    public static void main(String[] args) {
        for (int i = 1; i <= 4; i++) {
            println(f(i));
        }
    }
}
